// pages/wx_zm_book_home/home.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    clientHeight: 0,
    first_class_selected_index:0,
    second_class_selected_index:0,
    filter_class_selected_index:0,
    first_class_list: [],
    second_class_list: [],
    filter_class_list: [],
    isShowFilter: 0
  },
  getClientHeight:function() {
    this.setData({
      clientHeight: app.globalData.clientHeight
    })
  },
  /**
   * 一级类型
   * */
  getFirstClass:function() {
    this.setData({
      first_class_list: [{
          id: 0,
          classname: "全部"
        }, {
          id: 1,
          classname: "恋爱"
        }, {
          id: 2,
          classname: "古风"
        }, {
          id: 3,
          classname: "爆笑"
        }, {
          id: 4,
          classname: "奇幻"
        }, {
          id: 5,
          classname: "校园"
        }, {
          id: 6,
          classname: "都市"
        }]
    })
  },
  /**
   * 二级类型
   */
  getSecondClass: function(){
    this.setData({
      second_class_list:[{
          id:0,
          second_classname:"推荐"
        }, {
          id: 1,
          second_classname: "最热"
        }, {
          id: 2,
          second_classname: "最新"
        }]
    })
  },
  /**
   * 筛选条件
   */
  getFilterClass: function() {
    this.setData({
      filter_class_list:[{
          id:0,
          filter_classname:"全部"
        }, {
          id: 1,
          filter_classname: "连载"
        }, {
          id: 2,
          filter_classname: "完结"
        }]
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getClientHeight()
    this.getFirstClass()
    this.getSecondClass()
    this.getFilterClass()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  select_first_class:function(e) {
    this.setData({
      first_class_selected_index: e.currentTarget.dataset.itemid
    })
  },
  select_second_class:function(e) {
    this.setData({
      second_class_selected_index: e.currentTarget.dataset.itemid
    })
  },
  select_filter: function() {
    console.log("点击筛选")
    var status = 0;
    if (this.data.isShowFilter == 0){
      status = 1
    } else {
      status = 0
    }
    this.setData({
      isShowFilter: status
    })
  },
  select_filter_class: function(e) {
    this.setData({
      filter_class_selected_index: e.currentTarget.dataset.itemid
    })
  }
})